package Chapter8;

import org.apache.commons.lang3.time.StopWatch;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
 * Created by m.zabarylo on 10/10/2014.
 */
public class StopWatchDemo {
    private WebDriver driver;

    @Before
    public void setUp()
    {
        driver = new FirefoxDriver();
    }

    @Test
    public void testBMI() throws Exception
    {
        //get the StopWatch Object and start the StopWatch
        StopWatch pageLoad = new StopWatch();
        pageLoad.start();
        //open BMI
        driver.get("http://dl.dropbox.com/u/55228056/bmicalculator.html");
        //wait for the calc button
        new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("Calculate")));
        //stop the StopWatch
        pageLoad.stop();
        System.out.println("Total Page Load Time " + pageLoad.getTime() +" milliseconds");
    }
    @After
    public void tearDown()
    {
        driver.quit();
    }

}
